<?php

session_start();
include_once( 'config.php' );
include_once( 'saet.ex.class.php' );

if( !isset($_SESSION['last_key']) )  header("Location: index.php");

$c = new SaeTClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
$o = new SaeTOAuth( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
//$ms  = $c->home_timeline(); // done

if( isset($_REQUEST['q']) )
{
    // Search Public Timeline
    $params = array();
    $params['q'] = $_REQUEST['q'];
    $params['count'] = $_REQUEST['count'];
    $params['page'] = $_REQUEST['page'];
	$params['callback'] = $_REQUEST['callback'];

    $content = $o->oAuthRequest( 'http://api.t.sina.com.cn/statuses/search.json', 'GET', $params );

    header("Content-type:application/javascript; charset=utf-8");
	echo $content;

}

?>
